<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
        <meta charset="UTF-8">
        <title>编辑仪表</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="__HOME_CSS__/font.css">
        <link rel="stylesheet" href="__HOME_CSS__/xadmin.css">
        <script src="__HOME_JS__/echarts.min.js"></script>
        <script src="__HOME_LIB__/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="__HOME_JS__/xadmin.js"></script>
        <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
        <!--[if lt IE 9]>
            <script src="__HOME_JS__/html5.min.js"></script>
            <script src="__HOME_JS__/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                    <div class="layui-form-item">
                        <label for="L_serial" class="layui-form-label">
                            <span class="x-red">*</span>编号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_serial" name="serial" value="{$device.device_serial}" required=""  autocomplete="off" class="layui-input"></div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_device_name" class="layui-form-label">
                            <span class="x-red">*</span>设备名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_device_name" name="device_name" value="{$device.device_name}" required="" autocomplete="off" class="layui-input"></div>
                    </div>
                    <div class="layui-form-item">
                        <label for="category_id" class="layui-form-label">
                            <span class="x-red">*</span>设备类别</label>
                        <div class="layui-input-inline">
                            <select id="category_id" name="category_id">
                                <option value="">选择设备类别</option>
                                {volist name="category_list" id="vo"}
                                {if $vo.id==$device.category_id}
                                <option value="{$vo.id}" selected>{$vo.name}</option>
                                {else}
                                <option value="{$vo.id}">{$vo.name}</option>
                                {/if}
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_model" class="layui-form-label">
                            <span class="x-red">*</span>型号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_model" name="model" value="{$device.device_model}" required="" autocomplete="off" class="layui-input"></div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_warning_time" class="layui-form-label">
                            <span class="x-red">*</span>预警时间</label>
                        <div class="layui-input-inline">
                            <input  class="layui-input" placeholder="检修时间"  autocomplete="off" value="{$device.warning_time}" name="warning_time" id="L_warning_time">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_check_time" class="layui-form-label">
                            <span class="x-red">*</span>检修时间</label>
                        <div class="layui-input-inline">
                            <input  class="layui-input" placeholder="检修时间"  autocomplete="off" value="{$device.check_time}" name="check_time" id="L_check_time">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_scrap_time" class="layui-form-label">
                            <span class="x-red">*</span>报废时间</label>
                        <div class="layui-input-inline">
                            <input  class="layui-input" placeholder="报废时间" autocomplete="off" value="{$device.scrap_time}" name="scrap_time" id="L_scrap_time">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_rfid" class="layui-form-label">
                            <span class="x-red">*</span>绑定电子标签</label>
                        <div class="layui-input-inline">

                            <input type="text" id="L_rfid" name="rfid" required="" value="{$device.rfid}"  autocomplete="off" class="layui-input"><!-- <a class="layui-btn"  >设置</a>-->
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_repass" class="layui-form-label"></label>
                        <button class="layui-btn" lay-filter="add" lay-submit="">确认编辑仪表</button>
                    </div>
                </form>
            </div>
        </div>
        <script>layui.use(['form', 'layer','jquery','laydate'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;

                //监听提交
                form.on('submit(add)',
                    function(data) {
                        var serial = data.field.serial
                        var device_name = data.field.device_name;
                        var model = data.field.model;
                        var rfid = data.field.rfid;
                        var check_time = data.field.check_time;
                        var warning_time = data.field.warning_time;
                        var scrap_time = data.field.scrap_time;
                        var category_id = data.field.category_id;
                        $.ajax({
                            type: 'post',
                            url: "{:url('index/device/device_edit')}",
                            data: {serial: serial, device_name: device_name,model: model, rfid: rfid, check_time:check_time, warning_time:warning_time,scrap_time:scrap_time,category_id:category_id, id:{$device.id}},
                            success: function (res) {
                                if (res.code === 0) {
                                    layer.msg("修改成功", {
                                            icon: 6
                                        },
                                        function() {
                                            //关闭当前frame
                                            xadmin.close();

                                            // 可以对父窗口进行刷新
                                            xadmin.father_reload();
                                        });
                                }else {
                                    layer.msg(res.msg,{icon:2})
                                }
                            }
                        });
                        return false;
                    });
                var laydate = layui.laydate;

                //执行一个laydate实例
                laydate.render({
                    elem: '#L_scrap_time' //指定元素
                });

                //执行一个laydate实例
                laydate.render({
                    elem: '#L_check_time' //指定元素
                });
                //执行一个laydate实例
                laydate.render({
                    elem: '#L_warning_time' //指定元素
                });
            });</script>
    </body>

</html>